package com.itheima.mall.api.ums;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mall.mapper.ums.UmsMemberLevelMapper;
import com.itheima.mall.pojo.ums.UmsMemberLevel;
import com.itheima.mall.vo.R;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class UmsMemberLevelServiceImpl implements UmsMemberLevelServiceApi{

    @Autowired
    UmsMemberLevelMapper umsMemberLevelMapper;

    @Override
    public R listUmsMemberLevel(Integer defaultStatus) {

        LambdaQueryWrapper<UmsMemberLevel> lqw = new LambdaQueryWrapper<>();
        lqw.eq(UmsMemberLevel::getDefaultStatus,defaultStatus);

        List<UmsMemberLevel> umsMemberLevels = umsMemberLevelMapper.selectList(lqw);

        if (!ObjectUtil.isNull(umsMemberLevels)){
            return R.succeed(umsMemberLevels,"查询成功");
        }
        return R.error("查询失败");
    }
}
